#ifndef SSDP_H
#define SSDP_H

#ifdef __cplusplus
extern "C" {
#endif

#define SSDP_MULTICAST_IP "239.255.255.250"
#define SSDP_MULTICAST_PORT 1900

    
typedef struct {
    char srv_type[64];
    char srv_name[64];
    char location[64];
    int expiration;
}ssdp_dev_t;


/*
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 1
ST: urn:dial-multiscreen-org:service:dial:1
USER-AGENT: Google Chrome/65.0.3325.181 Windows
*/
/*
M-SEARCH * HTTP/1.1
S: uuid:ijklmnop-7dec-11d0-a765-00a0c91e6bf6
Host: 239.255.255.250:1900
Man: "ssdp:discover"
ST: ge:fridge
MX: 3

HTTP/1.1 200 OK
S: uuid:ijklmnop-7dec-11d0-a765-00a0c91e6bf6
Ext:
Cache-Control: no-cache="Ext", max-age = 5000
ST: ge:fridge
USN: uuid:abcdefgh-7dec-11d0-a765-00a0c91e6bf6
AL: <blender:ixl><http://foo/bar>
*/
int ssdp_msearch(const char *st, int tmo, ssdp_dev_t *dev); 
/*
NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
NT: blenderassociation:blender
NTS: ssdp:alive
USN: someunique:idscheme3
AL: <blender:ixl><http://foo/bar>
Cache-Control: max-age = 7393
*/
int ssdp_notify_alive(ssdp_dev_t*dev);
/*
NOTIFY * HTTP/1.1
Host: 239.255.255.250:1900
NT: someunique:idscheme3
NTS: ssdp:byebye
USN: someunique:idscheme3
*/
int ssdp_notify_byebye(ssdp_dev_t*dev);



int ssdp_start_service(ssdp_dev_t *ssdp_dev);
void ssdp_stop_service();


#ifdef __cplusplus
}
#endif

#endif
